 import { Component, OnInit, Input, EventEmitter, Output, Host, Inject, forwardRef, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Service } from '../../../server/server';
import { HintsService } from '../../../public/serve/hints/hints.service';
import { RemoveTableService } from '../../../public/serve/remove-table/remove-table.service';
declare var $: any;

interface Response {
  result: string[];
  result_code: string;
  message: string;
}

@Component({
  selector: 'app-roles-delete',
  templateUrl: './roles-delete.component.html',
})
export class RolesDeleteComponent implements OnInit {


  constructor(private http: HttpClient, private server: Service, private removeTableService: RemoveTableService,private hintsService:HintsService) { }

  ngOnInit() {
  }

  @Output()
  deleteOutput: EventEmitter<string> = new EventEmitter();

  // 确认删除
  confirmDel() {
    let body = {
      roleGroupId: this.removeTableService.getRemoveTableId,
    }
    let url = this.server.baseUrl+'admin/roleGroups/deleteInfo';
    //console.log(body)
    this.http.post<Response>(url, body).subscribe(res => {
      this.deleteOutput.emit(res.result_code);
      //console.log(res);
      this.hintsService.messages(res.message,res.result_code);
      if (res.result_code == '0000') {
        $("#delete").modal("hide");
        this.removeTableService.getRemoveTableId = [];
      }
      else {
        this.removeTableService.getRemoveTableId = [];
      }
    })
  }
}
